package com.map.m.loom;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

/**
 * Hello world!
 *
 */
public class App {
    public static void main(String[] args) throws InterruptedException {

        ThreadFactory factory = Thread.ofPlatform().factory();
        List<Thread> r = new ArrayList<>();
        for (int i = 0; i < 1000; i++) {
            int f = i;
            Thread th = factory.newThread(() -> {

                try {
                    Thread.sleep(1000_000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            });
            r.add(th);
            th.start();
            System.out.println(f);
        }
        r.stream().forEach(th -> {
            try {
                th.join();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        });
    }
}
